<template>
  <div class="exchange-item">
    <div class="top">
      <span class="title">{{info.useScopeRemarks}}</span>
      <div>
        <span>{{Number(this.info.coupleAmount).toFixed(2)}}</span>
        <span>元</span>
      </div>
      <span class="coupon">洗衣券</span>
    </div>
    <div class="divide"></div>
    <div class="bottom">
      <van-button
        type="primary"
        round
        @click='onExchangeClick'
      >兑换</van-button>
    </div>
  </div>
</template>


<script>
import { Button } from "vant";
export default {
  name: "ExchangeItem",
  components: {
    [Button.name]: Button,
  },
  props: {
    exchangeInfo: {
      type: Object,
      default: {},
    },
  },
  watch: {
    exchangeInfo: {
      deep: true,
      handler: function (newVal) {
        this.info = newVal;
      },
    },
  },
  data() {
    return {
      info: {},
    };
  },
  created() {
    this.info = this.exchangeInfo;
  },
  methods: {
    onExchangeClick() {
      this.$emit("onExchangeClick", this.info);
    },
  },
};
</script>

<style scoped lang="less">
.exchange-item {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  width: 30%;
  height: auto;

  .top {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    background: #ffffff;
    background: linear-gradient(135deg, transparent 0, #ffffff 0) top left,
      linear-gradient(-135deg, transparent 0, #ffffff 0) top right,
      linear-gradient(-45deg, transparent 10px, #ffffff 0) bottom right,
      linear-gradient(45deg, transparent 10px, #ffffff 0) bottom left;
    background-size: 50% 50%;
    background-repeat: no-repeat;
    width: 100%;
    height: 100%;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;

    .title {
      width: 190px;
      height: auto;
      background: #e4effe;
      border-radius: 0px 0px 12px 12px;
      font-size: 22px;
      color: #3b6bd8;
      line-height: 36px;
      text-align: center;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
    }

    div {
      display: flex;
      flex-direction: row;
      justify-content: center;
      align-items: center;
      width: 100%;
      margin-top: 20px;

      span:first-child {
        height: 100px;
        font-size: 86px;
        font-weight: bold;
        color: #df5438;
        line-height: 100px;
      }

      span:last-child {
        font-size: 24px;
        font-weight: 500;
        color: #df5438;
        line-height: 33px;
        margin-top: 30px;
      }
    }

    .coupon {
      margin-bottom: 30px;
      font-size: 24px;
      font-weight: 500;
      color: #222222;
      line-height: 33px;
    }
  }

  .divide {
    width: 80%;
    height: 1px;
    border: 1px dashed #d8bcbf;
  }

  .bottom {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 76px;
    box-sizing: border-box;
    background: linear-gradient(135deg, transparent 10px, #ffffff 0) top left,
      linear-gradient(-135deg, transparent 10px, #ffffff 0) top right,
      linear-gradient(-45deg, transparent 0, #ffffff 0) bottom right,
      linear-gradient(45deg, transparent 0, #ffffff 0) bottom left;
    background-size: 50% 50%;
    background-repeat: no-repeat;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;

    .van-button--primary {
      height: 40px;
      padding: 0 26px;
      background: #3f87f0;
      font-size: 26px;
      font-weight: 500;
      color: #ffffff;
      border: none;
    }
  }
}
</style>
